internal: simplify lexer using .to_slice() to eliminate allocations#5476
Merged
internal: simplify lexer using .to_slice() to eliminate allocations#5476
Conversation
Use chumsky 0.10's `.to_slice()` method to eliminate unnecessary `Vec<char>` allocations in the lexer: - `parse_integer()`: Changed return type from `Vec<char>` to `&str` - `ident_part()`: Simplified using `.to_slice()` instead of manual char collection - `param()`: Added `.to_slice()` before final string conversion - `keyword()`: Added `.to_slice()` and resolved TODO comment - `number()`: Cascading simplifications in fraction and exponent parsing This eliminates ~4+ Vec allocations per token for identifiers, numbers, and parameters, resulting in more efficient and idiomatic chumsky 0.10 code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Additional simplifications to eliminate Vec<char> allocations: - `raw_string()`: Use `.to_slice()` instead of collecting to Vec<char> - `digits()` helper: Changed return type from `Vec<char>` to `&str` - `time_component()`: Updated to accept `&str` instead of `Vec<char>` - Date/time parsing: Eliminated several Vec allocations in timestamp parsing - Clarified TODO comment about date_inner() requiring enum changes These changes further reduce allocations in the lexer, particularly for date/time literals and raw strings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplify the lexer by using chumsky 0.10's
.to_slice()method to eliminate unnecessaryVec<char>allocations.Changes
parse_integer(): Changed return type fromVec<char>to&str, using.to_slice()instead of manual char collectionident_part(): Simplified plain identifier parsing using.to_slice()param(): Added.to_slice()before final string conversionkeyword(): Added.to_slice()and resolved TODO commentnumber(): Cascading simplifications in fraction and exponent parsingImpact
Eliminates ~4+
Vec<char>allocations per token for identifiers, numbers, and parameters. More efficient and idiomatic chumsky 0.10 code with zero functionality changes.Test plan
🤖 Generated with Claude Code